

run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year <2013


* Table 1 baseline
  
global full_spc_baseline  keep($interaction  $p_control $prov_control ) lab  nocons  dec(3)   // alpha(0.01, 0.05, 0.1)

reghdfe  sec_promotion first_con_ps  $i_control ,  absorb(year cityID) cluster(cityID)
est store m1

reghdfe  sec_promotion first_con_ps  $i_control $p_control ,  absorb(year cityID ) cluster(cityID)
est store m2

reghdfe  sec_promotion $interaction   $i_control  ,  absorb(year cityID) cluster(cityID)
est store m3

reghdfe  sec_promotion $interaction   $i_control $p_control,  absorb(year cityID) cluster(cityID)
est store m4

reghdfe  sec_promotion $interaction  $prov_control $p_control  $i_control ,  absorb(year cityID ) cluster(cityID)
est store m5

outreg2 [m1 m2 m3 m4 m5] using "baseline.tex", replace ///
  addtext(Prefecture and Year FE, Y, Individual Controls,Y ) $full_spc_baseline 

	
* Figure 2 marginal effect plot  

reghdfe   sec_promotion  c.purge_cen_cum##first_con_ps $prov_control $p_control   $i_control, absorb(cityID year ) cluster(cityID)
margins ,dydx(first_con_ps) at(purge_cen_cum = (0(1)9))

marginsplot, plot1opts(lcolor(gs8)) ciopt(color(black%20)) yline(0)  title("") xtitle("Purge Intensity") ytitle("Effect of Connections on Political Turnover") 

*graph  export /Users/zerenli1992/Dropbox/Apps/Overleaf/li_manion_2020/mplot.png, replace


* Figure 3 visualize marginal effect
*Graph Settings
grstyle clear
set scheme plotplain

reghdfe   sec_promotion  c.prov_xi_faction##c.first_con_ps##c.purge_cen_cum $prov_control $p_control   $i_control, absorb(cityID year) cluster(cityID)

margins, dydx(first_con_ps) at(purge_cen_cum = (0(1)9) prov_xi_faction=(0 1)) 

marginsplot,  plot1opts(lpattern("1")) plot2opts(lpattern("--")) addplot(scatter y x  ) yline(0, lcolor(grey) lpattern("dashed")) ///
title("") xtitle("Purge Intensity") ytitle("Effect of Connections on Political Turnover") ///
legend(label(1 "Xi's Faction" 2 "Not Xi's Faction")) 


* Table 2: Effect of Purge on Political Selection in Pre-Campaign Period

clear 

run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year >= 2013
 
reghdfe  sec_promotion first_con_ps  $i_control ,  absorb(year cityID) cluster(cityID)
est store m1


reghdfe  sec_promotion first_con_ps  $i_control $p_control ,  absorb(year cityID ) cluster(cityID)
est store m2

reghdfe  sec_promotion $interaction   $i_control  ,  absorb(year cityID) cluster(cityID)
est store m3

reghdfe  sec_promotion $interaction   $i_control $p_control,  absorb(year cityID) cluster(cityID)
est store m4

reghdfe  sec_promotion $interaction  $prov_control $p_control  $i_control ,  absorb(year cityID ) cluster(cityID)
est store m5

outreg2 [m1 m2 m3 m4 m5] using "pre_campaign.tex", replace   ///
  addtext(Prefecture and Year FE, Y, Individual Controls,Y ) lab /// 
	 keep($interaction  $p_control $prov_control )  nocons  dec(3) 
  
	
	
